/*
** Copyright (C) 2010 Calin Radoni
**
** This file is part of CHScanner.
**
** CHScanner is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** CHScanner is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with CHScanner. If not, see <http://www.gnu.org/licenses/>.
*/

#include "StdAfx.h"
#include "MDHCPInfo.h"

//---------------------------------------------------------------------------

MDHCPInfo::MDHCPInfo(void)
{
	Initialize();
}

MDHCPInfo::~MDHCPInfo(void)
{
	optList.Clear();
}

//---------------------------------------------------------------------------

void MDHCPInfo::Initialize(void)
{
	isEmpty = true;
	hLen    = 0;
	yiAddr  = 0;
	siAddr  = 0;
	giAddr  = 0;
	memset(chAddr, 0, 16);
	optList.Clear();
}

//---------------------------------------------------------------------------

void MDHCPInfo::LoadFromPointer(MDHCPInfo* infoIn)
{
	MDHCPOption* opt;
	int i, cnt;

	Initialize();
	if(infoIn==NULL) return;

	isEmpty = infoIn->isEmpty;

	hLen   = infoIn->hLen;
	yiAddr = infoIn->yiAddr;
	siAddr = infoIn->siAddr;
	giAddr = infoIn->giAddr;
	memcpy(chAddr, infoIn->chAddr, 16);
	
	cnt = infoIn->optList.GetSize();
	for(i=0; i<cnt; i++){
		opt = infoIn->optList.GetByIdx(i);
		if(opt!=NULL)
			optList.Add(opt);
	}
}

//---------------------------------------------------------------------------
